{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import geoviews as gv\n",
    "import geoviews.tile_sources as gvts\n",
    "\n",
    "from geoviews import dim\n",
    "\n",
    "gv.extension('bokeh')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Declare data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "cities = pd.read_csv('../../assets/cities.csv', encoding=\"ISO-8859-1\")\n",
    "\n",
    "points = gv.Points(cities, ['Longitude', 'Latitude'], ['City', 'Population', 'Country', 'Year'],\n",
    "                   label='Top 20 Cities by population in 2050').select(Year=2050).sort('Population').iloc[-20:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(gvts.CartoMidnight *\n",
    " points.opts(\n",
    "    size=gv.dim('Population')*0.000002, fill_color='Population', line_color='gray', cmap='viridis',\n",
    "    width=700, height=600, global_extent=True, tools=['hover'], show_legend=False) *\n",
    " gv.Labels(points).opts(\n",
    "    text_font_size='8pt', text_color='white'))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
